package com.woniuxy.joylifemarket.scheduler;

import com.woniuxy.joylifemarket.service.MarketCommodityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Slf4j
@Component
public class HeatStatusScheduler {
    //占位符，读取配置文件中Spring EL表达式的值
    @Value("${scheduler.log.days}")
    private Integer days;
    @Autowired
    MarketCommodityService marketCommodityService;

    //cron表达式，每晚凌晨执行一次
    @Scheduled(cron = "0 0 0 */1 * ?")
    public void autoDeleteLog() {
        //获取更新条数
        int count = marketCommodityService.changeCommodityHeatStatus();
        System.out.println("更新了"+count+"条数据状态，时间："+new Date());
    }

}
